package com.db;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import com.bean.Passage;
import com.utils.JDBCUtils;

public class PassageDetailDao {
	//查询选择的passage
    public Passage queryPassage(int passageID)
    		throws Exception,ClassNotFoundException,
            IllegalAccessException, InstantiationException, SQLException 
    {
    	Connection conn = null;
    	Statement stmt = null;
    	ResultSet rs = null;
    	String getEmail,getPassword;
		conn = JDBCUtils.getConnection();
		stmt = conn.createStatement();
		String sql = "SELECT * FROM passage where passageID='" + passageID + "'";
		rs = stmt.executeQuery(sql);
		Passage passage = new Passage();
		
		try {
            while (rs.next()) {

                passage.setPassageID(rs.getInt("passageID"));
                passage.setTitle(rs.getString("title"));
                passage.setAuthorName(rs.getString("authorName"));
                passage.setContent(rs.getString("passageContent"));
                passage.setDate(rs.getString("passageDate"));
                passage.setCost(rs.getInt("cost"));
                passage.setDays(rs.getInt("days"));
                passage.setCity(rs.getNString("city"));
                passage.setAuthorID(rs.getString("authorID"));
                passage.setAuthorID(rs.getString("authorID"));
                passage.setLike(rs.getInt("likeNum"));

            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
		return passage;
    }

}
